# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=snapper
pkgver=0.8.12
pkgrel=0
pkgdesc="Manage filesystem snapshots and allow undo of system modifications"
url="http://snapper.io"
arch="all"
license="GPL-2.0-or-later"
options="!check" # 5 tests failing - https://github.com/openSUSE/snapper/issues/526
depends="dbus"
makedepends="acl-dev autoconf automake bash boost-dev
	boost-thread bsd-compat-headers btrfs-progs-dev
	dbus-dev docbook-xsl e2fsprogs-dev gettext-dev
	libtool libxml2-dev libxslt lvm2-dev"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
source="$pkgname-$pkgver.tar.gz::https://github.com/openSUSE/snapper/archive/v$pkgver.tar.gz
	musl-posix.patch
	musl-mktime.patch
	musl-stdout_stderr.patch
	musl-_nl_msg_cat_cntr.patch
	musl-u_int_type.patch
	remove-systemd.patch
	"

prepare() {
	default_prepare
	autoreconf -fi
	# rename cron scripts
	sed -i -e 's@suse.de-@@g' scripts/Makefile.am
	# copy cron scripts to /etc/periodic/* instead of /etc/cron.*
	sed -i -e 's/cron\./periodic\//g' scripts/Makefile.am
	# fix config location in cron scripts
	sed -i -e 's@/etc/sysconfig/@/etc/conf.d/@g' scripts/snapper-daily
	sed -i -e 's@/etc/sysconfig/@/etc/conf.d/@g' scripts/snapper-hourly
}

build() {
	export LDFLAGS="$LDFLAGS -lintl"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sbindir=/usr/sbin \
		--disable-silent-rules \
		--with-conf=/etc/snapper \
		--disable-pam \
		--disable-zypp \
		--disable-ext4 \
		--disable-systemd
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm644 data/sysconfig.snapper "$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="b06b6c2b928caf66d6426649ca9f47cd710b8495d636d77d2cbbd232902a62dce56df5501c24d0f1c1d71ca524a00c9375976397c4f2b36898f08a07b871c6d8  snapper-0.8.12.tar.gz
a9eec8105e94c4eb097aa293754b0de45420a297ad845933a7be66b3ff49af409dd427e9bd1de569c49982c619211d1e90183ed8bf8550acb0fa9d83176e22bf  musl-posix.patch
ca59aaa4411abf51136b25ee8dd57fae6fc01ce21c36ac79811b4ed8b4352c5b396ce42b7c4c49d8679a9bef8375fe48b65c1ff84bbf1f192583f3b93dce1bd8  musl-mktime.patch
5baf722996706146b62fd0a0d9b321496fb122e700af2d3dfd8272de2678f29c79bc2b1a03634b04aab3f226632dfdebc5674d3128737e85bcc71461e951d95b  musl-stdout_stderr.patch
6f3324700cc697b29b2fe14e42eb765b4474bf7e582d8ea53122fe66e128d17584489c8e2adbfecc8aac37c683a9d4dc2a821e3ea0143334cd8b899164ba708c  musl-_nl_msg_cat_cntr.patch
36bc62b09f1795c955de603e6faa92b640b772182f00e1c192edada9b327a7433a6541d62f2d77cf1c1c0f42958409d66f987f03db75a1140b0d17b77f666bc8  musl-u_int_type.patch
4c843d204c5da81686d5b8b99708ec73dd504969cbd9189feeb3f69db95f15b96d242c010ad48afa7d5ca76ecbe3a0c806bc1af9ffb70a7945201fd12f3b3d3b  remove-systemd.patch"
